FROM php:7.2-fpm
COPY sources.list /etc/apt/sources.list

ENV PHPREDIS_VERSION 4.0.2
ENV PHPMONGODB_VERSION 1.4.3
ENV PHPAMQP_VERSION 1.7.1
ENV PHPSWOOLE_VERSION 4.0.3
ENV PHPMEMCACHED_VERSION 3.0.4 
ENV RABBITMQC_VERSION 0.8.0

RUN apt-get update \
    && apt-get install -y git apt-utils wget libfreetype6-dev libjpeg62-turbo-dev libpng-dev pkg-config build-essential libmemcached-dev libssl-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && :\
    && apt-get install -y libicu-dev \
    && docker-php-ext-install intl \
    && :\
    && apt-get install -y libxml2-dev \
    && apt-get install -y libxslt-dev \
    && apt-get install -y libldap2-dev \
    && docker-php-ext-install soap \
    && docker-php-ext-install xsl \
    && docker-php-ext-install xmlrpc \
    && docker-php-ext-install wddx \
    && docker-php-ext-install ldap \
    && :\
    && apt-get install -y libbz2-dev \
    && docker-php-ext-install bz2 \
    && :\
    && docker-php-ext-install zip \
    && docker-php-ext-install pcntl \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-install mysqli \
    && docker-php-ext-install mbstring \

    && echo "install memcached extension pecl" \
    && curl -L -o /tmp/memcached-$PHPMEMCACHED_VERSION.tgz http://pecl.php.net/get/memcached-$PHPMEMCACHED_VERSION.tgz \
    && tar xfz /tmp/memcached-$PHPMEMCACHED_VERSION.tgz \
    && mv package.xml memcached-$PHPMEMCACHED_VERSION \
    && rm -r /tmp/memcached-$PHPMEMCACHED_VERSION.tgz \
    && cd memcached-$PHPMEMCACHED_VERSION \
    && phpize && ./configure && make && make install \
    && echo "extension=memcached.so">/usr/local/etc/php/conf.d/memcached.ini \

    && echo "install swoole extension" \
    && curl -L -o /tmp/swoole-$PHPSWOOLE_VERSION.tgz http://pecl.php.net/get/swoole-$PHPSWOOLE_VERSION.tgz \
    && tar xfz /tmp/swoole-$PHPSWOOLE_VERSION.tgz \
    && mv package.xml swoole-$PHPSWOOLE_VERSION \
    && rm -r /tmp/swoole-$PHPSWOOLE_VERSION.tgz \
    && cd swoole-$PHPSWOOLE_VERSION \
    && phpize && ./configure && make && make install \
    && echo "extension=swoole.so">/usr/local/etc/php/conf.d/swoole.ini \

    && echo "install redis extension" \
    && curl -L -o /tmp/redis-$PHPREDIS_VERSION.tgz http://pecl.php.net/get/redis-$PHPREDIS_VERSION.tgz \
    && tar xfz /tmp/redis-$PHPREDIS_VERSION.tgz \
    && mv package.xml redis-$PHPREDIS_VERSION \
    && rm -r /tmp/redis-$PHPREDIS_VERSION.tgz \
    && cd redis-$PHPREDIS_VERSION \
    && phpize && ./configure && make && make install \
    && echo "extension=redis.so">/usr/local/etc/php/conf.d/redis.ini \

    && echo "install mongodb extension" \
    && curl -L -o /tmp/mongodb-$PHPMONGODB_VERSION.tgz http://pecl.php.net/get/mongodb-$PHPMONGODB_VERSION.tgz \
    && tar xfz /tmp/mongodb-$PHPMONGODB_VERSION.tgz \
    && mv package.xml mongodb-$PHPMONGODB_VERSION \
    && rm -r /tmp/mongodb-$PHPMONGODB_VERSION.tgz \
    && cd mongodb-$PHPMONGODB_VERSION \
    && phpize && ./configure && make && make install \
    && echo "extension=mongodb.so">/usr/local/etc/php/conf.d/mongodb.ini \



    && echo "install rabbitmq-c" \
    && curl -L -o /tmp/rabbitmq-c-$RABBITMQC_VERSION.tar.gz http://www.dahouduan.com/wp-content/uploads/2017/11/rabbitmq-c-$RABBITMQC_VERSION.tar.gz \
    && tar xvzf /tmp/rabbitmq-c-$RABBITMQC_VERSION.tar.gz \
    && rm -r /tmp/rabbitmq-c-$RABBITMQC_VERSION.tar.gz \
    && cd rabbitmq-c-$RABBITMQC_VERSION \
    && ./configure \
    && make && make install \

    && echo "install rabbitmq extension" \
    && curl -L -o /tmp/amqp-$PHPAMQP_VERSION.tgz http://pecl.php.net/get/amqp-$PHPAMQP_VERSION.tgz \
    && tar xfz /tmp/amqp-$PHPAMQP_VERSION.tgz \
    && mv package.xml amqp-$PHPAMQP_VERSION \
    && rm -r /tmp/amqp-$PHPAMQP_VERSION.tgz \
    && cd amqp-$PHPAMQP_VERSION \
    && phpize && ./configure && make && make install \
    && echo "extension=amqp.so">/usr/local/etc/php/conf.d/amqp.ini \

    && echo "Cleaning..." \
    && apt-get purge -y --auto-remove \
        -o APT::AutoRemove::RecommendsImportant=false \
        -o APT::AutoRemove::SuggestsImportant=false \
        $buildDeps \
    && rm -rf /var/cache/apt/* \
    && rm -rf /var/lib/apt/lists/*